import backtrader as bt
import pandas as pd
import datetime
from utils.turn2100 import trans


def ploti(data0, cerebro, currency="BNB"):
    dataframe = pd.read_csv("data/%sUSDT/data.csv" % currency)
    dataframe = trans(dataframe)
    dataframe['open_time'] = pd.to_datetime(dataframe['open_time'])
    dataframe.set_index('open_time', inplace=True)
    dataframe['openinterest'] = 0
    data_ = bt.feeds.PandasData(
        dataname=dataframe,
        fromdate=datetime.datetime(2019, 10, 15),
        todate=datetime.datetime(2020, 11, 9)
    )
    data_.plotinfo.plotmaster = data0
    cerebro.adddata(data_, name=currency)
    cerebro.run()
    cerebro.plot()
